// 功能相近的程序封装成代码块


//普通函数
function findMan(age:number):string{
  return 'find the '+ age + 'years'
}


//有可选参数的函数
function findPeople(age:number,name?:string):string{
  if(name){
    return 'find the '+ age + 'years and name is'+ name;
  }else{
    return 'find the '+ age +'and no name!';
  }
}

//有剩余参数的函数

function findRest(age:number,...xuqiu:string[]):string{
  let yy = "";
  for(let i=0; i< xuqiu.length;i++){
     yy = yy + xuqiu[i];
     if(i < xuqiu.length -1){
          yy = yy +'、'
     }
  }
  return '需求有：'+yy;
}


var age:number = 18;
var result:string = findMan(age);
var resule2:string = findPeople(22,"HaoRen");
var resule3:string = findRest(22,'美女','人妖','SM','SB');

console.log(result);
console.log(resule2);
console.log(resule3);